package cn.com.ethos.search.query;

import org.json.JSONStringer;

public class ExceptionResponse extends Response {

	private Exception exception;
	
	public ExceptionResponse(Exception ex) {
		this.status = 0;
		this.exception = ex;
	}
	
	@Override
	protected String getBody() {
		
		JSONStringer json = new JSONStringer();
		try{
			return json.object()
					   .key("msg").value(this.exception.getMessage())
					   .key("stack").value(this.exception.getStackTrace())
					   .endObject()
					.toString();		
		}catch(Exception ex) {
			return this.getSimpleExceptionBody(ex);
		}
	}

}
